package com.service;

import com.data.UserDAO;
import com.data.Login;

public class LoginService {
    public  int check(String name,String pwd,String yan,String yuan,String xi){
        if(!yan.equals("8774")){
            return -1;
        }
        UserDAO dao=new UserDAO();
        Login l=dao.check(name,pwd);
        if(l!=null){
            if(!yuan.equals("1")){
                return -3;
            }
            if(!xi.equals("1")) {
                return -4;
            }
            return 1;

        }
        else{
            return -2;
        }
    }
    public  String failure(int result){
        String error;
        if(result==-1){
            error="验证码错误";
        }
        else if(result==-2){
            error="用户名或密码错误";
        }
        else if(result==-3){
            error="学院错误";
        }
        else{
            error="所在系错误";
        }
        return error;
    }
    public int getUId(String name,String pwd){
        UserDAO dao=new UserDAO();
        return dao.getUid(name,pwd);
    }
}
